home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / snpd9611.zip / FASKBHIT.C < prev    next >
C/C++ Source or Header  |  1996-11-24  |  1KB  |  59 lines

  1. .I 0 3
  2. /* +++Date last modified: 23-Nov-1996 */
  3.  
  4. /*
  5. .D 1 1
  6. .I 2 3
  7. **
  8. **  Revisions:
  9. **  30-Mar-96  Ed Blackman  OS/2 mods
  10. .I 6 1
  11. #include "snipkbio.h"
  12. .I 10 30
  13. #if defined(__OS2__)
  14.  
  15. /* 30-Mar-96 - EBB:  it really isn't good to poll the keyboard in OS/2.
  16. ** A better design would be to call KbdCharIn(..., IO_WAIT, ...) in a
  17. ** separate thread, and sending a message via some form of IPC to the main
  18. ** thread when a key is available.  This code is intended to be more of an
  19. ** example of how to use the API, rather than something you would copy into
  20. ** production code.
  21. */
  22.  
  23. int fast_kbhit_os2(void)
  24. {
  25.     extern KBDKEYINFO ki;         /* defined in ISSHIFT.C */
  26.  
  27.     KbdPeek(&ki, 0);              /* peek in the keyboard buffer */
  28.     DosSleep(1);                  /* give up the rest of the time slice */
  29.  
  30.     return (ki.fbStatus & (1 << 6));  /* only return true if key is 'final' */
  31. }
  32.  
  33. void fast_kbflush_os2(void)
  34. {
  35.     KbdFlushBuffer(0);
  36. }
  37.  
  38. #else   /* assume DOS */
  39.  #define biosseg 0x40
  40.  
  41.  #define HEAD (*((unsigned short FAR *)MK_FP(biosseg, 0x1a)))
  42.  #define TAIL (*((unsigned short FAR *)MK_FP(biosseg, 0x1c)))
  43. .D 11 4
  44. .I 21 6
  45.       int retval;
  46.  
  47.       disable();
  48.       retval = HEAD - TAIL;
  49.       enable();
  50.       return retval;
  51. .D 22 1
  52. .I 30 5
  53.       disable();
  54.       HEAD = TAIL;
  55.       enable();
  56. }
  57. #endif  /* !__OS2__ */
  58. .D 31 2
  59.